﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

using LanguageDetector;

namespace LanguageDetector.Test
{
    [TestFixture]
    public class Extension01_Clean
    {
        [Test]
        public void T01_DIGIT()
        {
            var inputs = new List<string> 
            {
                "123456789",
                "1,235,335.23",
                "99.356.333,1",
                ".023",
                ",1235",
            };
            inputs.ForEach(s =>
            {
                var r = s.Clean(CleanLevel.Digit);
                Assert.AreEqual(string.Empty, r.Trim(), "Clean failed for input: {0}", s);
            });
        }

        [Test]
        public void T02_MARKING()
        {
            var inputs = new List<string> 
            {
                @"~!@#$ $$% ^%^&&* ((**() __++=-",
                @"[]\{{\}}|;; ;'',. <,.>> /? """,
            };
            inputs.ForEach(s =>
            {
                var r = s.Clean(CleanLevel.Marking);
                Assert.AreEqual(string.Empty, r.Trim(), "Clean failed for input: {0}", s);
            });
        }

        [Test]
        public void T03_ALPHABET()
        {
            var inputs = new List<string> 
            {
                @"abcdk OIdksiE joIJDF jkwejfk",
                @"QFJ jzvndsND NDfnow DFjopwevds joqiwznm",
                @"qwertyuiop QWERTYUIOP asdfghjkl ASDFGHJKL zxcvbnm ZXCVBNM",
            };
            inputs.ForEach(s =>
            {
                var r = s.Clean(CleanLevel.Alphabet);
                Assert.AreEqual(string.Empty, r.Trim(), "Clean failed for input: {0}", s);
            });
        }

        [Test]
        public void T04_WHITE_SPACE()
        {
            var inputs = new List<string> 
            {
                "\r\n",
                "\t \r\n    \t \t \r\t\n  ",
            };
            inputs.ForEach(s =>
            {
                var r = s.Clean(CleanLevel.Alphabet);
                Assert.AreEqual(string.Empty, r.Trim(), "Clean failed for input: {0}", s);
            });
        }

        [Test]
        public void T05_TAG()
        {
            var inputs = new List<string> 
            {
                " <b>test</b> ",
                "test<br />",
                "test<br/>",
                " <a href='http://www.test.com/?p=122&k=efe' alt=\"me 2...\">test</a> ",
                " <link rel='135t' /> test ",
                " <!-- abc -->test",
            };
            inputs.ForEach(s =>
            {
                var r = s.Clean(CleanLevel.Tag);
                Assert.AreEqual("test", r.Trim(), "Clean failed for input: {0}", s);
            });
        }
    }
}
